//
//  MoreTeamCell.m
//  WE
//
//  Created by iMacOne on 15/11/21.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "MoreTeamCell.h"
#import "Head.h"

@interface MoreTeamCell ()
@property (nonatomic, strong)UILabel * nameLabel;
@property (nonatomic, strong)UILabel * proLabel;
@property (nonatomic, strong)UILabel * contentLabel;

//@property (nonatomic, strong)UIImageView * icon1;
//@property (nonatomic, strong)UIImageView * icon1;
//@property (nonatomic, strong)UIImageView * icon1;


@end

@implementation MoreTeamCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10*Width, 20*Height, 100, 20*Height)];
        self.nameLabel.font = FONT(14);
        self.nameLabel.text = @"杨建民专家团队";
        
        for (int i = 0; i < 3; i++) {
            UIImageView * aImageView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_nameLabel.frame) + (i + 1)*10*Width + i *30*Width, 15*Height, 30*Width, 30*Width)];
            aImageView.backgroundColor = DEBUG_CLOLR;
            aImageView.layer.masksToBounds = YES;
            aImageView.layer.cornerRadius = 15*Width;
            [self.contentView addSubview:aImageView];
        }
        self.proLabel = [[UILabel alloc] initWithFrame:CGRectMake(10*Width,CGRectGetMaxY(_nameLabel.frame)+ 20*Height, 35, 20*Height)];
        self.proLabel.font = FONT(14);
        self.proLabel.text = @"擅长:";
        _proLabel.textColor = CONTENTCOLOR;
        
        
        self.contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(10*Width, CGRectGetMaxY(_proLabel.frame) + 10 * Height, WindowWidth - 20, margin_30)];
        _contentLabel.font = FONT(12);
        _contentLabel.text = @"杨建民专家团队杨建民专家团队杨建民专家团队杨建民专家团队杨建民专家团队杨建民专家团队杨建民专家团队杨建民专家团队杨建民专家团队";
        _contentLabel.numberOfLines = 0;
        _contentLabel.textColor = CONTENTCOLOR;

        NSArray * arr = @[@"杨建民专家团队",@"杨建民专家团队",@"杨建民专家团队",@"杨建民专家团队",@"杨建民专家团队",@"杨建民专家团队"];
        
        float x = 0;
            for (int j = 0; j < arr.count; j++) {
                float y = [ToolUtil autoWidth:arr[j] width:0 height:20*Height num:12];
                x += y;
                UILabel * lbl = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_proLabel.frame) + (j + 1)* 5*Width + x - y ,_proLabel.frame.origin.y , [ToolUtil autoWidth:arr[j] width:0 height:20*Height num:12], 20*Height)];
                lbl.font = FONT(12);
                lbl.text = arr[j];
                lbl.textColor = [UIColor orangeColor];
                lbl.layer.borderWidth = 1;
                lbl.layer.borderColor = [UIColor orangeColor].CGColor;
                
                float z = 0;
                if (CGRectGetMaxX(lbl.frame) > WindowWidth - 20*Width) {
                    
                    self.contentLabel.frame =  CGRectMake(10*Width, CGRectGetMaxY(_proLabel.frame) + 30 * Height, WindowWidth - 20*Width, margin_30);
                    for (int i = 0; i < arr.count - j; i ++) {
                        float t = [ToolUtil autoWidth:arr[j] width:0 height:20*Height num:12];
                        z += t;
                        lbl.frame = CGRectMake(CGRectGetMaxX(_proLabel.frame) + (i + 1)* 5*Width + z - t,CGRectGetMaxY(_proLabel.frame) + 3*Height, [ToolUtil autoWidth:arr[j] width:0 height:20*Height num:12], 20*Height);
                        if (z>WindowWidth - 100) {
                            break ;
                        }
                    }

                    }
                
                [self.contentView addSubview:lbl];
           
        }

        
    
        

        
        
    
        
        [self.contentView addSubview:_nameLabel];
        [self.contentView addSubview:_proLabel];
        [self.contentView addSubview:_contentLabel];
//        [self.contentView addSubview:self.moreButton];
    }
    return self;
}

@end
